package com.rocksdata.mc.business;

import android.content.Context;

import com.rocksdata.mc.BuildConfig;
import com.rocksdata.mc.MobileCampusApplication;

import cn.jpush.android.api.JPushInterface;

public class PushManager implements BusinessInterface.IPushManager {
    private static final int SEQUENCE_SET_ALIAS = 100;
    private static final int SEQUENCE_DELETE_ALIAS = 101;

    private static BusinessInterface.IPushManager instance;

    private Context context;

    static synchronized BusinessInterface.IPushManager getInstance() {
        if (instance == null)
            instance = new PushManager();
        return instance;
    }

    private PushManager() {
        context = MobileCampusApplication.getContext();
    }

    @Override
    public void initPushService() {
        JPushInterface.init(context);
        JPushInterface.setDebugMode(BuildConfig.DEBUG);
    }

    @Override
    public void bindPushRelation() {
        JPushInterface.setAlias(context, SEQUENCE_SET_ALIAS, UserInfoManager.getCurrentUserId());
    }

    @Override
    public void unbindPushRelation() {
        JPushInterface.deleteAlias(context, SEQUENCE_DELETE_ALIAS);
    }
}
